package com.aglow.bluetoothspeaker.main.ui.fragment;

import android.os.Bundle;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aglow.bluetoothspeaker.R;
import com.aglow.bluetoothspeaker.main.base.BaseFragment;
import com.aglow.bluetoothspeaker.model.bean.Music;
import com.aglow.bluetoothspeaker.utils.SpManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;


public class MusicInfoFragment extends BaseFragment {
    @BindView(R.id.fragment_song)
    TextView fragmentSong;
    @BindView(R.id.fragment_singer)
    TextView fragmentSinger;
    private Music currMusic;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_music_info, container, false);
    }

    @Override
    public void initData() {
        Log.i("musicList","978189657816t5");
        EventBus.getDefault().register(this);
    }

    @Override
    public void initView() {

    }

    @Override
    public void addViewListener() {

    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void updateMusicInfo(Music music){
        currMusic = music;
        Log.i("musicList","music.getArtist() = "+music.getArtist());
        Log.i("musicList","music.getFileName() = "+music.getArtist());

        fragmentSinger.setText(music.getArtist());
        fragmentSong.setText(music.getFileName().substring(music.getFileName().indexOf("-")+1));

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
